package com.xx.job.controller.system;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xx.job.common.PageResult;
import com.xx.job.common.Result;
import com.xx.job.controller.dto.PageDTO;
import com.xx.job.entity.system.SysJob;
import com.xx.job.service.system.SysJobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;
import com.xx.job.controller.base.BaseController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liangcy
 * @since 2021-01-14
 */
@RestController
@RequestMapping("/api/v1")
public class SysJobController extends BaseController {

    @Autowired
    private SysJobService sysJobService;

    @RequestMapping("/sysjob")
    public Result operloglist(PageDTO pageDTO, SysJob sysJob){
        IPage<SysJob> sysOperaLogIPage;
        sysOperaLogIPage = sysJobService.selectPage(pageDTO, sysJob);
        return Result.success(new PageResult(sysOperaLogIPage));
    }

    @PostMapping("/sysjob")
    public Result addOperlog(@RequestBody SysJob sysJob){
        return Result.success(sysJobService.add(sysJob));
    }

    @DeleteMapping("/sysjob/{id}")
    public Result deleteOperlog(@PathVariable Long id){
        return Result.success(sysJobService.delete(id));
    }

    @PutMapping("/sysjob")
    public Result updateOperlog(@RequestBody SysJob sysJob){
        return Result.success(sysJobService.update(sysJob));
    }

    @GetMapping("/sysjob/{id}")
    public Result selectOperlog(@PathVariable Long id){
        return Result.success(sysJobService.select(id));
    }
}

